﻿function gofigure(formname)
{
	var decoded=[0,2,0,0,1,0,1,0,0,0,8,0,8,0,0,0,0,0,0,8,0,0,4,0,2,0,0,0,0,0,0,4,0,0,2,0,4,0,0,0,0,0,0,0,0,1,1,0,0,0,0,8,8,0,0,0,4,0,0,0,0,0,0,4,4,0,0,0,1,0,0,0,0,0,0,2,2,0,0,0,2,0,0,0,0,1,0,0,1,0];
	var tally=[0,0,0,0,2,2];
	var checked=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];
	var i;
	var j;
	var away; away=0; var home; home=0;

	if (formname.a.checked){checked[1]=1} else {checked[1]=0};
	if (formname.b.checked){checked[2]=1} else {checked[2]=0};
	if (formname.c.checked){checked[3]=1} else {checked[3]=0};
	if (formname.d.checked){checked[4]=1} else {checked[4]=0};
	if (formname.e.checked){checked[5]=1} else {checked[5]=0};
	if (formname.f.checked){checked[6]=1} else {checked[6]=0};
	if (formname.g.checked){checked[7]=1} else {checked[7]=0};
	if (formname.h.checked){checked[8]=1} else {checked[8]=0};
	if (formname.i.checked){checked[9]=1} else {checked[9]=0};
	if (formname.j.checked){checked[10]=1} else {checked[10]=0};
	if (formname.k.checked){checked[11]=1} else {checked[11]=0};
	if (formname.l.checked){checked[12]=1} else {checked[12]=0};
	if (formname.m.checked){checked[13]=1} else {checked[13]=0};
	if (formname.n.checked){checked[14]=1} else {checked[14]=0};
	if (formname.o.checked){checked[15]=1} else {checked[15]=0};

	for (i=0;i<15;i++) {
		if (checked[i+1]){
			for (j=0; j<6; j++){
				tally[j]=(tally[j]+decoded[(i*6+j)])%16;
			}
		}
		if ((i<7)&&(checked[i+1])){away++};
		if ((i>6)&&(i<14)&&(checked[i+1])){home++};
	}

    j=" ";
    for (i=0;i<6;i++) {
    	if (tally[i]==10){tally[i]="A"} else
    	if (tally[i]==11){tally[i]="B"} else
    	if (tally[i]==12){tally[i]="C"} else
    	if (tally[i]==13){tally[i]="D"} else
    	if (tally[i]==14){tally[i]="E"} else
    	if (tally[i]==15){tally[i]="F"};
    	j=j+tally[i]+" ";
    	if (i==2){j=j+"- "};
    }
	formname.result.value=j;
	if (away>home+1){formname.result.value="請再勾選主場比賽";};
	if (away<home)  {formname.result.value="請再勾選客場比賽";};
}